/*******************************************************************************
				FIGURE 3
*******************************************************************************/

*WAGE IV, COWORKERS
*FIGURE 3 PANEL A: SENSITIVITY ANALYSIS.

cap{
use "$data/fig3A.dta", clear
local xi edad edad2 sexo anos_educ puntaje lnw 
local xg m_l_edad m_l_sexo m_l_puntaje m_l_anos_educ

foreach delta of numlist 60000(2500)90000{
qui ivreg sej2012 `xi' `xg' (l_net = z_lnet) if h==`delta', cluster(rut_emp) 
parmest, saving("$results/cow_window_`delta'", replace) idnum(`delta') level(90 95)
}
use "$results/cow_window_60000.dta", clear
cap erase "$results/cow_window_60000.dta"
foreach delta of numlist 62500(2500)90000{
append using "$results/cow_window_`delta'"
cap erase "$results/cow_window_`delta'.dta"
}
keep if parm=="l_net"

tw (connected estimate idnum, lc(black) mc(black)) ///	
	(line min90 idnum, lpattern(dash) lcolor(black)) ///
	(line max90 idnum, lpattern(dash) lcolor(black)), ///
	yline(0, lc(black)) ///
	ylabel(-0.2(0.2)1, format(%3.2fc)) ymlabel(-0.1(0.1)1,nolabel) ///
	ytitle("Estimated peer effect {&beta}") ///
	xline(70000,lp(dash) lc(black)) ///
	xlabel(60000(10000)90000, format(%10.0gc)) ///
	xmlabel(60000(2500)90000,nolabel) ///
	xtitle("Wide of {&Delta} (in CLP$)") ///	
	legend(off) ///
	scheme(s1color) ///
	name("Figure3_PanelA", replace)
	graph export "$results/Figure3_PanelA.pdf", replace
	}
	
********************************************************************************
	
*WAGE IV, CLASSMATES
*FIGURE 3 PANEL B: SENSITIVITY ANALYSIS.

cap{

use "$data/fig3B.dta", clear
local xi edad edad2 sexo anos_educ puntaje lnw
local xg m_s_edad m_s_sexo m_s_puntaje m_s_anos_educ 

foreach delta of numlist 60000(2500)90000{
qui ivreg sej2012 `xi' `xg' (s_net = z_snet) if h==`delta', cluster(rbd)
parmest, saving("$results/class_window_`delta'", replace) idnum(`delta') level(90 95)
}
use "$results/class_window_60000", clear
cap erase "$results/class_window_60000.dta"
foreach delta of numlist 62500(2500)90000{
append using "$results/class_window_`delta'"
cap erase "$results/class_window_`delta'.dta"
}
keep if parm=="s_net"

tw (connected estimate idnum, lc(black) mc(black)) /// 
	(line min90 idnum, lpattern(dash) lcolor(black)) ///
	(line max90 idnum, lpattern(dash) lcolor(black)), ///
	yline(0, lc(black)) ///
	ylabel(-0.2(0.2)1, format(%3.2fc)) ymlabel(-0.1(0.1)1,nolabel) ///
	ytitle("Estimated peer effect {&beta}") ///
	xline(65000,lp(dash) lc(black)) ///
	xlabel(60000(10000)90000, format(%10.0gc)) ///
	xmlabel(60000(2500)90000,nolabel) ///
	xtitle("Wide of {&Delta} (in CLP$)") /// 	
	legend(off) ///
	scheme(s1color) ///
	name("Figure3_PanelB", replace)
	graph export "$results/Figure3_PanelB.pdf", replace
}
